#include <stdlib.h>
#include <stdio.h>
/*
NOTE: THIS PROGRAM CURRENTLY DOES NOT RUN

Needle in a Haystack
Functions:

TestNeedle(void,int HaystackPos) - for(int iIndex;index < needlesize;iIndex++) - looks through a possible needle part of a char array

LookForNeedle(char haystack[],needle[]) - Loops through haystack looking for the first character of the needle, when that is found it runs TestPossibleNeedle()

Author: http://code.google.com/p/machs-code-sandbox/ - Mach1723

License: GPL V3
*/

int TestNeedle(int iHaystackPos);
int LookForNeedle(char *haystack,char *needle);

int main(void)
{
LookForNeedle("","");
return 0;
}




#include <stdio.h>
#include <stdlib.h>

int TestNeedle(int iHaystackPos)
{

}

int LookForNeedle(char *haystack,char *needle) //get the length of the needle and haystack after user input(need to learn dynamic memory allocation)
{
int bytesize = 512;

haystack = malloc(bytesize); //malloc attempts to allocate 512 bytes for haystack and needle
needle = malloc(bytesize);

haystack = "\0";//character to look for to see if realloc() is needed. 
needle = "\0";

char *pHaystack;
char *pNeedle;

pHaystack = haystack;
pNeedle = needle;

if(haystack == NULL || needle == NULL) //checks memory alloc success or fail.
	{
	puts("Memory Allocation failed, not enough memory, exiting.");
	return 1;
	}

int index;
	
while(index < bytesize)
	{
	pHaystack = "\0"; //inits the pointers
	pNeedle = "\0";
	index++;
	}
	
puts("Enter the Haystack");
fgets(pHaystack, bytesize,stdin);

if(pHaystack == NULL) //checks if pHaystack is null and needs resizing
	{
	bytesize += 512;
	realloc(pHaystack, bytesize);
	
	
	if(pHaystack == NULL)
		{
		puts("memory allocation failed, exiting");
		return 1;
		}
	}


}